import java.util.Arrays;

public class test {
    public static void func1(int n){
        n = 10;
    }
    public static void main7(String[] args) {
        int[] a = {1,2,3,4,5,6};
        func1(a[2]);//传过去的是整型--但以这种方式无法改变数组中的值
        //没有 &a[2]一说
        System.out.println(Arrays.toString(a));
    }
    /*
        数组传参
     */
    public static void func2(int[] array){
        array = new int[10];//不重分配啊
    }
    public static void func1(int[] array){
        array[0] = 99;
    }
    public static void main6(String[] args) {
        int[]array = {1,2,3,4,5,6};
       // func1(array);
        func2(array);
        System.out.println(Arrays.toString(array));
    }
    //
    public static void main5(String[] args) {
        int[] array = null;
        //空引用
    }
    public static void main4(String[] args) {
        int[] arr1 = {1,2,3,4};
        int[] arr2 = {2,3,4,5,6};
        arr1 = arr2;
        System.out.println(Arrays.toString(arr1));
    }
    public static void main3(String[] args) {
        int[] arr = new int[10];
        System.out.println(arr);//类似地址
        int[]array1 = {1,2,3,4};
        /*String ret = Arrays.toString(array1);
        System.out.println(ret);
        System.out.println(array1);*/
        int[]array2 = array1;
       /* System.out.println(array2);
        String ret2 = Arrays.toString(array2);
        System.out.println(ret2);*/
    }
    public static void main2(String[] args) {
        int[]arrary = {1,2,3};
        int[] arrary2 = new int[]{1,2,3};
        int[] arrary3 = new int[3];//默认0
        //访问for循环、foreach、Arrays
        for(int x : arrary3){
            System.out.println(x);
        }
    }
    //遍历数组
    public static void main1(String[] args) {
        int[] arr = new int[10];
        for(int i =0;i<arr.length;i++){
            arr[i] = i+1;
        }
        String ret = Arrays.toString(arr);
        System.out.println(ret);
    }
}
